import { api } from "./api";

const login = function (account: string, password: string): Promise<string> {
  console.log(account, password);
  return new Promise((resolve, reject) => {
    api.post('/login', {
      account,
      password
    }).then(resp => {
      if (resp.data.code == 200) {
        resolve(resp.data.data.token);
      } else {
        reject(String(resp.data.code));
      }
    }).catch(e => {
      reject(e);
    })
  })
};

const loginByPhone = function (
  phoneNumber: string,
  valiCode: string
): Promise<string> {
  return new Promise<string>((resolve, reject) => {
    reject("no this phone");
  });
};

export { login, loginByPhone };
